#include <bits/stdc++.h>
using namespace std;
int n, m, K; vector<int> X;
vector<bool> Vis; vector<int> Dis; string A; deque<int> Q;
inline int ID(int x, int y, int z){return (x * n + y) * m + z;}
inline void push_back (int id, int dis){Q.push_back (id), Dis[id] = dis, Vis[id] = 1;}
inline void push_front(int id, int dis){Q.push_front(id), Dis[id] = dis, Vis[id] = 1;}
inline basic_string<int> get_nxt_0(int id){
  basic_string<int> res; int k = id / (n * m), x = id / m % n, y = id % m;
  if(!k){
    if(x && A[ID(0, x - 1, y)] == '.') res.push_back(ID(0, x - 1, y));
    if(y && A[ID(0, x, y - 1)] == '.') res.push_back(ID(0, x, y - 1));
    if(x + 1 < n && A[ID(0, x + 1, y)] == '.') res.push_back(ID(0, x + 1, y));
    if(y + 1 < m && A[ID(0, x, y + 1)] == '.') res.push_back(ID(0, x, y + 1));
  } else {
    res.push_back(ID(k - 1, x, y));
    if(x - X[k] + X[k - 1] >= 0) res.push_back(ID(k - 1, x - X[k] + X[k - 1], y));
    if(y - X[k] + X[k - 1] >= 0) res.push_back(ID(k - 1, x, y - X[k] + X[k - 1]));
    if(x - X[k] + X[k - 1] >= 0 && y - X[k] + X[k - 1] >= 0)
      res.push_back(ID(k - 1, x - X[k] + X[k - 1], y - X[k] + X[k - 1]));
  }
  return res;
}
inline basic_string<int> get_nxt_1(int id){
  basic_string<int> res; int k = id / (n * m), x = id / m % n, y = id % m;
  if(!k){
    if(x > 0) res.push_back(ID(X.size() - 1, x - 1, y));
    if(y > 0) res.push_back(ID(X.size() - 1, x, y - 1));
    if(x > 0 && y + 1 < m) res.push_back(ID(X.size() - 1, x - 1, min(y + K - 1, m - 1)));
    if(y > 0 && x + 1 < n) res.push_back(ID(X.size() - 1, min(x + K - 1, n - 1), y - 1));
    if(x + 1 < n) res.push_back(ID(X.size() - 1, min(x + K, n - 1), y));
    if(y + 1 < m) res.push_back(ID(X.size() - 1, x, min(y + K, m - 1)));
    if(x + 1 < n && y + 1 < m){
      res.push_back(ID(X.size() - 1, min(x + K - 1, n - 1), min(y + K, m - 1)));
      res.push_back(ID(X.size() - 1, min(x + K, n - 1), min(y + K - 1, m - 1)));
    }
  }
  return res;
}
int BFS(){
  int x_0, y_0, x_1, y_1; cin >> x_0 >> y_0 >> x_1 >> y_1;
  Vis.resize(X.size() * n * m), Dis.resize(X.size() * n * m);
  A.resize(n * m); for(int i = 0; i < n * m; i++) cin >> A[i];
  if(A[ID(0, --x_0, --y_0)] == '.') push_back(ID(0, x_0, y_0), 0);
  else{
    push_back(ID(X.size() - 1, x_0, y_0), 1);
    push_back(ID(X.size() - 1, min(x_0 + K, n) - 1, y_0), 1);
    push_back(ID(X.size() - 1, x_0, min(y_0 + K, m) - 1), 1);
    push_back(ID(X.size() - 1, min(x_0 + K, n) - 1, min(y_0 + K, m) - 1), 1);
  }
  while(!Q.empty()){
    int id = Q.front(); Q.pop_front();
    // cerr << id / (n * m) << ':' << id / m % n << ',' << id % m << ':' << Dis[id] << endl;
    for(int nxt: get_nxt_0(id)) if(!Vis[nxt]) push_front(nxt, Dis[id]    );
    for(int nxt: get_nxt_1(id)) if(!Vis[nxt]) push_back (nxt, Dis[id] + 1);
  }
  return Dis[ID(0, --x_1, --y_1)];
}
int main(){
  freopen("stamp.in", "r", stdin);
  freopen("stamp.out", "w", stdout);
  cin.tie(nullptr)->sync_with_stdio(false);
  cin >> n >> m >> K;
  for(int k = K; k > 1; k = (k + 1) >> 1) X.push_back(k);
  X.push_back(1), reverse(X.begin(), X.end());
  cout << BFS() << '\n';
  return 0;
}
